﻿@model Webcar.Entitys.BS_CAR_SEND

@{ Layout = "~/Views/Shared/_leftPanelLayout.cshtml";}
@section LeftTree
{
     
    @{
        Html.RenderPartial("DeptTreePartialView", new Webcar.Models.DeptTreeMode { Action = "List", Controller = "CarSend", ShowChild = false });
     }
}

    
@using (Html.BeginForm("Edit", "CarSend", Html.ViewContext.RouteData.Values,FormMethod.Post))
{
    @Html.AntiForgeryToken()
    <div id="edit-car" style="width:700px;margin:5px 5px 5px 5px">
    @Html.HiddenFor(a => a.XH)
    @Html.HiddenFor(a => a.car_no)
    @Html.HiddenFor(a => a.is_check)

        <table class="edit-table">
            <tr>
                <td style="width: 80px; text-align: right;">*所属单位：</td>
                <td>@Html.DropDownListFor(a => a.DEPT_CODE, WebcarDataHelper.UserSuperDeptList, new { @style = "width: 100%;", @onchange = "changeDept();" })</td>
                <td style="width: 80px; text-align: right">*用车部门：</td>
                <td>@Html.DropDownListFor(a => a.dept2, WebcarDataHelper.GetChildDeptByDeptList(Model.DEPT_CODE), new { @style = "width: 100%;" })</td>
                <td style="width: 80px; text-align: right">*用车监护人：</td>
                <td style="width: 150px">@Html.TextBoxFor(a => a.jhr, new { @style = "width: 100%;"})</td>
            </tr>

            <tr>
                <td style="text-align: right">*出车时间：</td>
                <td >@Html.CalendarFor(a=>a.START_DATE)</td>
                <td style="text-align: right">*申请人：</td>
                <td >@Html.TextBoxFor(a=>a.sqr)</td>
                <td style="text-align: right">*用车人数：</td>
                <td >@Html.TextBoxFor(a=>a.use_nums)</td>
            </tr>
            <tr>
                <td style="text-align: right">返回时间：</td>
                <td >@Html.CalendarFor(a=>a.END_DATE)</td>
                <td style="text-align: right"></td>
                <td ></td>
                <td style="text-align: right"></td>
                <td ></td>
            </tr>

            <tr>
                <td style="text-align: right">运输物资：</td>
                <td colspan="3">@Html.TextBoxFor(a=>a.material)</td>
                
                <td style="text-align: right">数量(T)：</td>
                <td >@Html.TextBoxFor(a=>a.material_nums)</td>
            </tr>

            <tr>
                <td style="text-align: right;">*用车事由：</td>
                <td colspan="5">@Html.TextAreaFor(a=>a.REASON,4,30,new{style="width:100%"})</td>
            </tr>
            <tr>
                <td style="text-align: right;">*往返地点：</td>
                <td colspan="5">@Html.TextAreaFor(a=>a.PLACE,4,30,new{style="width:100%"})</td>
            </tr>


        </table>
        <div id="div_check">
        <hr />
        <div style="text-align:center;color:red;font-weight:bold">审核内容</div>
        <div style="text-align:center;color:red">提示：必须输入车号和驾驶员，派车单才视为已审核。</div>
        <hr />
            <table class="edit-table">
                <tr>
                    <td style="width: 80px; text-align: right;">*车牌号：</td>
                    <td>@Html.TextBox("RecordNo",(string)@ViewBag.RecordNo)</td>
                    <td style="width: 80px; text-align: right">*驾驶员：</td>
                    <td style="width: 150px">@Html.TextBoxFor(a => a.driver_name)</td>
                    <td style="width: 80px; text-align: right">*用工类别：</td>
                    <td>@Html.DropDownListFor(a=>a.job_kind,new SelectList(WebcarDataHelper.JobKind,"Item1","Item2"))</td>
                </tr>
                <tr>
                    <td style="width: 80px; text-align: right">*派车人：</td>
                    <td>@Html.TextBoxFor(a=>a.send_man)</td>
                    <td style="width: 80px; text-align: right">起始公里：</td>
                    <td style="width: 150px">@Html.TextBoxFor(a => a.StartMile)</td>
                    <td style="width: 80px; text-align: right">截至公里：</td>
                    <td>@Html.TextBoxFor(a => a.EndMile)</td>
                </tr>
                <tr>
                    <td style="text-align: right;">安全交底：</td>
                    <td colspan="5">@Html.TextAreaFor(a=>a.sec_cause,3,30,new{style="width:100%"})</td>
                </tr>
                <tr>
                    <td style="text-align: right;">备注：</td>
                    <td colspan="5">@Html.TextAreaFor(a=>a.REMARK,3,30,new{style="width:100%"})</td>
                </tr>
            </table>
        </div>
        <div class="validation-errors">@ViewBag.ErrorMessage</div>
        <hr />
    </div>
    
    <table style="width:700px">
        <tr>
            <td style="width:650px;"></td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.Name = "Button1";
                    settings.Text = CurrentUser.CheckPermission(PermissionManager.填写派车单) ? "保存" : "无权限";
                    settings.Enabled = CurrentUser.CheckPermission(PermissionManager.填写派车单);
                    settings.UseSubmitBehavior = true;
                    settings.Width = 70;
                    settings.ControlStyle.CssClass = "button1";
                }).GetHtml()
                

            </td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.ControlStyle.CssClass = "button2";
                    settings.Name = "Button2";
                    settings.Text = "取消";
                    settings.Width = 70;
                    settings.ClientSideEvents.Click = "function(s, e){history.back(); }";
                }).GetHtml()
            </td>
        </tr>

    </table>
}
 

<script type="text/javascript">
    $(function () {
        

        var purview_flag = '@CurrentUser.CheckPermission(PermissionManager.派车审核权限)';
        if (purview_flag == 'False') {
            $("div_check").css("display", "none");
        }
        changeDept();
    
        $("#RecordNo").change(function () {
            $("#car_no").val("");
        });
    });
    function changeDept() {
        setCarAutoComplete("RecordNo", $("#DEPT_CODE").val(),
            '@Url.Action("GetAutoCompleteCar","Common")',
            function (event, ui) {
                $("#car_no").val(ui.item.key);
            }
        );
        retriveChildDept2("DEPT_CODE", "dept2");

        setDriverAutoComplete("driver_name", $("#DEPT_CODE").val(), '@Url.Action("GetAutoCompleteDriver","Common")',
            function (event, ui) {
                $("#driver_name").val(ui.item.value);
            });
    };

</script>    